/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swingDemoEvent;

import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;

public class ActionEventTest2 extends JFrame
        implements ActionListener {

    JTextField t1 = new JTextField("abc");
    JButton b1 = new JButton("change");
    JButton b2 = new JButton("exit");

    public ActionEventTest2() {
        setLayout(new FlowLayout());
        b1.addActionListener(this);

        setSize(200, 200);
        setVisible(true);
        add(b1);
        add(b2);
        add(t1);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        t1.setText("农大");
        t1.setFont(new Font("黑体", Font.ITALIC, 20));
        t1.setSize(100, 50);
        t1.setForeground(Color.red);
    }

    public static void main(String[] args) {
        ActionEventTest2 ic = new ActionEventTest2();
    }
}
